package xyz.scootaloo.draft;

import java.util.HashSet;
import java.util.Set;

/**
 * @author flutterdash@qq.com
 * @since 2021/3/31 21:47
 */
public class Case5 {

    public static void main(String[] args) {
        CompareObj objA = new CompareObj(13);
        CompareObj objB = new CompareObj(17);
        CompareObj objC = new CompareObj(12);
        Set<CompareObj> set = new HashSet<>();
        set.add(objA);
        set.add(objA);
        set.add(objB);
        set.add(objB);
        System.out.println(set.size());           // 2
        System.out.println(set.contains(objA));   // true
        System.out.println(set.contains(objC));   // false
    }

    private static class CompareObj {
        final int num;
        public CompareObj(int num) {
            this.num = num;
        }

        @Override
        public int hashCode() {
            return 1;
        }
    }

}
